package elitech.vietnam.weatherfashion.weatherservice;

import android.util.Log;

public class WeatherService {

	private OpenWeatherMapService openWeatherMapService;
	//private WunderGroundWeatherService wunderGroundWeatherService;

	public WeatherService() {
		openWeatherMapService = new OpenWeatherMapService();
		//wunderGroundWeatherService = new WunderGroundWeatherService();
	}

	public WeatherObject getWeather(String lat, String lon) {

		try {
			Log.i("GPS-Weather", "Start get weather base");
			WeatherObject result = openWeatherMapService.getWeatherByLocation(
					lat, lon);
			Log.i("GPS-Weather", "Stop get weather base");

//			if (result != null) {
//				Log.e("GPS-Weather", "Start get weather list template");
//				result.setHourlyTemperature(wunderGroundWeatherService
//						.getHourlyTemprature(lat, lon));
//				Log.e("GPS-Weather", "Stop get weather list template");
//			}
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			Log.e("GPS-Weather", "error get weather " + e);
			return null;
		}
	}

	public WeatherObject getWeather(String cityName) {

		try {
			Log.i("GPS-Weather", "Start get weather base");
			WeatherObject result = openWeatherMapService
					.getWeatherByCity(cityName);
			Log.i("GPS-Weather", "Stop get weather base");

//			if (result != null) {
//				Log.e("GPS-Weather", "Start get weather list template");
//				result.setHourlyTemperature(wunderGroundWeatherService
//						.getHourlyTemprature(cityName));
//				Log.e("GPS-Weather", "Stop get weather list template");
//			}
			return result;
		} catch (Exception e) {
			e.printStackTrace();
			Log.e("GPS-Weather", "error get weather " + e);
			return null;
		}
	}

}
